console.log("At code start!");

var delayedPromise = new Promise((resolve, reject) => {
  console.log("promise execute！");
  setTimeout(() => {
    console.log("resolving delayed promise");
    resolve("success");
  }, 500);
});

console.log(delayedPromise !== null);
console.log("Aftewr creating delayed promise");

delayedPromise.then(data => {
  console.log(data);
});

const ImmediatePromise = new Promise((resolve, reject)=>{
  console.log("immediate promise executor. Immediate resolve");
  resolve("Immediate success");
});

ImmediatePromise.then(res => {
  console.log(res);
});

console.log(" At code end");

/**
 * 执行结果：
 
 At code start!
promise execute！
true
Aftewr creating delayed promise
immediate promise executor. Immediate resolve
At code end
Immediate success
undefined
resolving delayed promise
success
  
 * 
 */